package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {
    //根据用户名查询员工
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    //新增员工信息
    @Insert("insert into employee (name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status) " +
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    @AutoFill(OperationType.INSERT)//自动填充 createTime updateTime createUser updateUser
    void addEmployee(Employee pojo);
     //分页查询
    long countTotal(EmployeePageQueryDTO employeePageQueryDTO);
    List<Employee> page(EmployeePageQueryDTO employeePageQueryDTO);

     // 使用插件做分页查询
    Page<Employee> selectPage(EmployeePageQueryDTO employeePageQueryDTO);

    //更新员工信息
    @AutoFill(OperationType.UPDATE)//自动填充 createTime updateTime createUser updateUser
    void update(Employee employee);
    //查询员工信息 通过id
    @Select("select * from employee where id = #{id}")
    Employee getById(long id);
}
